<template>
	<view>
		<u-card padding="20" box-shadow="10rpx 10rpx 10rpx #c8c9cc" v-if="orders">
			<view slot="head"
				style="padding: 10rpx;display: flex;justify-content: space-between;font-weight: bold;padding-left: 0;font-size: 14px;">
				<view style="display: flex;justify-content: space-between;">
					<view style="max-width: 150rpx;white-space: nowrap;font-weight: bold;">
						<text>{{strToFormat(orders.take_date)}}</text>
						<u-icon name="arrow-rightward" style="margin: 0 10rpx;"></u-icon>
						<text>{{strToFormat(orders.return_date)}}</text>
						<text>（{{strDateToTime2(orders.take_date,orders.return_date)}}）</text>
					</view>
				</view>
				<view>
					<text v-if="orders.state_id==1">预定</text>
					<text v-if="orders.state_id==2">待出车</text>
					<text v-if="orders.state_id==3">已出车</text>
					<text v-if="orders.state_id==4">已还车</text>
					<text v-if="orders.state_id==5">已结算</text>
					<text v-if="orders.state_id==6">结束</text>
					<text v-if="orders.state_id==7">取消</text>
				</view>
			</view>
			<view slot="body" style="color: #000;font-weight: normal;" @click="toInfo(orders.orders_id)">
				<view style="margin-bottom: 20rpx;display: flex;">
					<text style="margin-left: 10rpx;font-weight: bold;">{{orders.myType.cx}}</text>
					<u-tag :text="orders.car_num" style="width: 200rpx;margin-left: 20rpx;" type="primary" />
				</view>
				<view style="display: flex;align-items: center;font-size: 14px;">
					<view>
						<text>订单号：</text>
						<text>{{orders.orders_num}}</text>
					</view>

				</view>
				<view>{{orders.car_type_name}}</view>
				<view style="margin-top: 20rpx;">
					<text>{{orders.take_date}}</text>
				</view>
				<view>
					<u-tag text="起" mode="dark" type="info" />
					<text style="margin-left: 20rpx;">{{orders.take_location}}</text>
				</view>
				<view style="margin-top: 20rpx;">
					<u-tag text="还" mode="dark" type="info" />
					<text style="margin-left: 20rpx;">{{orders.return_location}}</text>
				</view>
				<view>{{orders.return_date}}</view>
				<view style="margin-top: 20rpx;">
					<text>送车员：</text>
					<text>{{orders.employe_name}}</text>
				</view>
				<view style="margin-top: 20rpx;display: flex;">
					<view>
						<text>订单来源：</text>
						<text v-if="orders.orders_source_id==1">后台录入</text>
						<text v-if="orders.orders_source_id==2">系统商城</text>
						<text v-if="orders.orders_source_id==3">哈罗</text>
						<text v-if="orders.orders_source_id==4">飞猪</text>
						<text v-if="orders.orders_source_id==5">携程</text>
						<text v-if="orders.orders_source_id==6">滴滴打车</text>
						<text v-if="orders.orders_source_id==7">第三方推荐</text>
					</view>
					｜
					<view>
						<text v-if="orders.nonlocal_take_return==1">本地取还车</text>
						<text v-if="orders.nonlocal_take_return==2">异地取还车</text>
					</view>
				</view>
			</view>
			<!-- 地步 -->
			<view slot="foot">
				<view style="display: flex;justify-content: space-between;">
					<view style="display: flex;align-items: center;">
						<u-tag text="个人" type="primary" mode="light" v-if="orders.custom_type==1" />
						<u-tag text="单位" type="warning" mode="light" v-if="orders.custom_type==2" />
						<text style="margin-left: 10rpx;" v-if="orders.custom_name">{{orders.custom_name}}</text>
						<text style="margin-left: 10rpx;" v-else>{{orders.appt_name}}</text>
						<u-icon name="phone" color="#2979ff" size="35" style="margin-left: 10rpx;"
							@click="call(orders.custom_tel?orders.custom_tel:orders.appt_tel)"></u-icon>
					</view>
					<!-- 按钮 -->
					<view v-if="1==2">

						<u-button type="primary" plain size="mini" @click="toPage('replaceCar')">换车</u-button>
						<u-button type="primary" plain size="mini" style="margin-left: 20rpx;"
							@click="toPage('replaceEmploye')">换司机</u-button>
					</view>
					<view>
						<u-button type="primary" plain size="mini" @click="selectOrders(orders)">选择</u-button>
					</view>
				</view>
			</view>
		</u-card>
	</view>
</template>

<script>
	import dateUtils from '../../utils/dateUtils.js'
	export default {
		name: "OrderCard2",
		props: {
			orders: {
				type: Object
			},
			deposit_pay_id: Number
		},

		data() {
			return {};
		},
		mounted() {
			var that = this;

		},
		methods: {
			call(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber: phoneNumber
				})
			},
			toPage(e) {
				uni.navigateTo({
					url: '/pages/' + e + '/' + e + '?data=' + encodeURIComponent(JSON.stringify(this.orders))
				})
			},
			strToFormat(strDate) {
				return dateUtils.strToFormat(strDate);
			},
			strDateToTime2(take_date, return_date) {
				return dateUtils.strDateToTime2(take_date, return_date);
			},
			getOrdersInfo(orders_id) {
				var that = this;
				that.$http.post('/orders/queryById?orders_id=' + orders_id, {}, (res) => {
					if (res.data.success) {
						that.orders = res.data.result;
					} else {
						that.refs.myModal.show('请求失败', res.data.result.message);
					}
				});
			},
			selectOrders(orders) {
				var that = this;
				uni.$emit("returnSelectedOrders", orders);
				uni.navigateBack()
			},
			toInfo(orders_id) {
				uni.navigateTo({
					url: '/pages/ordersInfo/ordersInfo?orders_id=' + this.orders.orders_id
				})
			}
		}
	}
</script>

<style>

</style>